<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci= & get_instance();
	$USER = $ci->user_entity->init('id',$_SESSION['user']['id']);
?>
<div id="center-wrap" class="ui-corner-tl ui-corner-tr">
	<div id="navigation" class="ui-corner-all"><ul><?php echo $navigator;?></ul></div>
	
	<div class="clrboth"></div>
	
<form action="<?php echo site_url('seller/add_show/edit_show');?>" name="edit_show" id="edit_show" method="post" enctype="multipart/form-data" encoding="multipart/form-data" >
	
	<div class="row">
		<div class="column grid_9">
			<h1 class="bold capitalize">Edit show</h1>
		</div>
		<div class="clrboth"></div>
		<div class="column grid_9">
			<div class="column grid_2"><span class="red">*</span>Show Name:</div>
			<div class="column grid_4">
				<input type="text" maxlength="250" name="show_name" id="show_name" value="<?php echo $items->getName();?>" class="inputText" />
			</div>
			<div class="column grid_1 hidden" id="show_name_error">
				<span class="red">Required field.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Show type:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'show_type',
										$options = showTypeDataConfig(),
										$selected = explode(',', $items->getShowType()),
										"id='show_type' class='width270'"
									);?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Duration of show:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'show_duration',
										$options = durationOfShowDataConfig(),
										$selected = explode(',', $items->getShowDuration()),
										"id='show_duration' class='width270'"
									);	
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Artist:</div>
			<div class="column grid_4">
				<input type="text" maxlength="200" name="artist" id="artist" value="<?php echo $items->getArtist();?>" class="inputText" />
			</div>
			<div class="column grid_1 hidden" id="artist_error">
				<span class="red">Required field.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Country of origin:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'country_origin',
										$options = countryOriginDataConfig(),
										$selected = explode(',', $items->getCountryOriginCode()),
										"id='country_origin' class='width270'"
									);	
				?>
			</div>
			
			<div class="clrboth"></div>
			<div class="column grid_2"><span class="red">*</span>Bid Open To:</div>
			<div class="column grid_6">
				<div style="border:1px solid #cccccc;padding:5px;margin:5px 0px;">
					<?php 
						$bidOpen = "";
						$array = explode(',', $items->getBidType());
						foreach( bidOpenToDataConfig() as $key => $value){
							$checked = in_array($key, $array) ? 'checked="checked"': "";
							$bidOpen .= "<input $checked type='checkbox' name='bid_open[]' id='__$key' value='$key' />&nbsp;$value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
						}
						echo $bidOpen ;
					?>
					<div class="clrboth"></div>
					<span class="red hidden" id="bid_open_error">Required field.</span>
				</div>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2">Music Genre:</div>
			<div class="column grid_6">
				<div style="border:1px solid #cccccc;padding:5px;">
					<?php 
						$music_genre = "<table><tr>"; 
						$i = 0;
						$array = explode(',', $items->getMusicGenre());
						foreach ( musicGenreDataConfig() as $key => $value ){
							if($i % 3 == 0 AND $i!= 0){
								$music_genre .= "</tr><tr>";
							}
							$checked = in_array($key, $array) ? 'checked="checked"': "";
							$i++;
							$music_genre .= "<td width='250px;'><input $checked type='checkbox' name='music_genre[]' id='music_genre[]' value='$key' />&nbsp;$value</td>";
						}
						$music_genre .= "</tr></table>";	
						echo $music_genre;
					?>
					<div class="clrboth"></div>
					<span class="red hidden" id="music_genre_error">Required field.</span>
				</div>
			</div>
			
			<div class="clrboth"></div>
			<div class="column grid_2">Speaker Profile:</div>
			<div class="column grid_6">
				<div style="border:1px solid #cccccc;padding:5px;margin:5px 0px;">
					<?php 
						$speaker_profile = "<table><tr>";
						$i = 0;
						$array = explode(',', $items->getSpeakerProfile());
						foreach ( speakerProfileDataConfig() as $key => $value ){
							if($i % 3 == 0 AND $i!= 0){
								$speaker_profile .= "</tr><tr>";
							}
							$i++;
							$checked = in_array($key, $array) ? 'checked="checked"': "";
							$speaker_profile .= "<td width='250px;'><input $checked type='checkbox' name='speaker_profile[]' id='speaker_profile[]' value='$key' />&nbsp;$value</td>";
						}
						$speaker_profile .= "</tr></table>";	
						echo $speaker_profile;
					?>
					<div class="clrboth"></div>
					<span class="red hidden" id="speaker_profile_error">Required field.</span>
				</div>
			</div>
			
			<div class="clrboth"></div>
			<div class="column grid_2">Plays & Musicals:</div>
			<div class="column grid_6">
				<div style="border:1px solid #cccccc;padding:5px;margin:5px 0px;">
					<?php 
						$plays_musicals = "<table><tr>";
						$i = 0;
						$array = explode(',', $items->getPlaysMusicals());
						foreach ( playsMusicalsDataConfig() as $key => $value ){
							if($i % 3 == 0 AND $i!= 0){
								$plays_musicals .= "</tr><tr>";
							}
							$i++;
							$checked = in_array($key, $array) ? 'checked="checked"': "";
							$plays_musicals .= "<td width='250px;'><input $checked type='checkbox' name='plays_musicals[]' id='plays_musicals[]' value='$key' />&nbsp;$value</td>";
						}
						$plays_musicals .= "</tr></table>";	
						echo $plays_musicals;
					?>
					<div class="clrboth"></div>
					<span class="red hidden" id="plays_musicals_error">Required field.</span>
				</div>
			</div>
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Booking available for:</div>
			<div class="column grid_6">
				<div style="border:1px solid #cccccc;padding:5px;margin:5px 0px;">
					<?php 
						$available_for = "<table><tr>";
						$i = 0;
						$array = explode(',', $items->getAvailableFor());
						foreach ( countryZoneDataConfig() as $key => $value ){
							if($i % 3 == 0 AND $i!= 0){
								$available_for .= "</tr><tr>";
							}
							$i++;
							$checked = in_array($key, $array) ? 'checked="checked"': "";
							$available_for .= "<td width='250px;'><input $checked type='checkbox' name='available_for[]' id='available_for[]' value='$key' />&nbsp;$value</td>";
						}
						$available_for .= "</tr></table>";	
						echo $available_for;				
					?>
					<div class="clrboth"></div>
					<span class="red hidden" id="available_for_error">Required field.</span>
				</div>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Period of Travel:</div>
			<div class="column grid_6">
				<input type="text" name="start_date" id="start_date" value="<?php echo sbxDateFormat($items->getStartDate(),'d-F-Y')?>" size="25" /> 
				&nbsp;-&nbsp;
				<input type="text" name="end_date" id="end_date" value="<?php echo sbxDateFormat($items->getEndDate(),'d-F-Y')?>" size="25" />
				<div class="clrboth"></div>
				<span class="red hidden" id="period_error">Please choose valid start date and end date.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Bid Due Date:</div>
			<div class="column grid_6">
				<input type="text" name="bid_due_date" id="bid_due_date" value="<?php echo sbxDateFormat($items->getBidDueDate(),'d-F-Y')?>" size="25" /> 
				<span class="red hidden" id="bid_due_date_error">Please choose valid bid due date.</span>
			</div>
		 	
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Entourage Number:</div>
			<div class="column grid_5">
				<input type="text" maxlength="10" name="entourage_no" id="entourage_no" value="<?php echo $items->getEntourageNo();?>" class="inputText" /> PAX
			</div>
			<div class="column grid_1 hidden" id="entourage_no_error">
				<span class="red">Required field.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Min Bid:</div>
			<div class="column grid_5">
				<input type="text" maxlength="10" name="min_bid" id="min_bid" value="<?php echo $items->getMinBid();?>" class="inputText" /> USD
			</div>
			<div class="column grid_1 hidden" id="min_bid_error">
				<span class="red">Required field.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Air Travel:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'air_travel',
										$options = coBuyerOrSellerDataConfig(),
										$selected = explode(',', $items->getAirTravel()),
										"id='air_travel' class='width270'"
									);	
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Ground:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'ground',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getGround()),
										"id='ground' class='width270'"
									);
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Hotel:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'hotel',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getHotel()),
										"id='hotel' class='width270'"
									);	
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Per diem:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'per_diem',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getPerDiem()),
										"id='per_diem' class='width270'"
									);
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Light & Sound:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'light_n_sound',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getLightAndSound()),
										"id='light_n_sound' class='width270'"
									);
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Rider Requirement:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'rider_req',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getRiderReq()),
										"id='rider_req' class='width270'"
									);
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>VISA & Work Permits:</div>
			<div class="column grid_4">
				<?php echo form_dropdown( 'visa_n_work_permits',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array($items->getVisaAndWorkPermits()),
										"id='visa_n_work_permits' class='width270'"
									);
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Additional Information:</div>
			<div class="column grid_6">
				<textarea maxlength="1200" name="additional" id="additional" value="" cols="65" rows="10" ><?php echo $items->getAdditional();?></textarea>
				<div class="clrboth"></div>
				<span class="red hidden" id="additional_error">Required field.</span>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Upload tech rider:</div>
			<div class="column grid_4">
				<?php echo form_upload('tech_rider',"", 'id="tech_rider" size="30"');?>
				
				<div class="clrboth"></div>
				<span class="hidden" id="tech_rider_error"><span class="red">Required field.</span><br />
					Max file allow: <?php echo allowMaxFileSize();?> MB. <br/>
					Allow extension: <?php echo implode( ', ',allowExtensionFileDocumentUpload() );?>
				</span>
				<div class="clrboth"></div>
				<a href="<?php echo fileTarget($USER->getId(),$items->getTechRider());?>" target="_blank"><?php echo $items->getTechRider();?></a>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2"><span class="red">*</span>Upload show images<br/> (up to 3 images max):</div>
			<div class="column grid_4">
				<?php echo form_upload('show_image_1',"", 'id="show_image_1" size="30"');?> &nbsp;&nbsp; <a href="javascript:void(0);" onclick="add_more();">+ add more </a>
				<div class="clrboth"></div>
				<?php echo form_upload('show_image_2',"", 'id="show_image_2" size="30" class="hidden"' );?>
				<div class="clrboth"></div>
				<?php echo form_upload('show_image_3',"", 'id="show_image_3" size="30" class="hidden"');?>
				
				<div class="clrboth"></div>
				<span class="hidden" id="show_image_error"><span class="red">Required field.</span><br />
					Max file allow: <?php echo allowMaxFileSize();?> MB. <br/>
					Allow extension: <?php echo implode( ', ',allowExtensionPictureUpload() );?>
				</span>
				<div class="clrboth"></div>
				<?php if($items->getShowImage1()):?>
					<img src="<?php echo thumb(fileTarget($USER->getId(),$items->getShowImage1()),80,80);?>" /> 
					&nbsp;&nbsp;&nbsp;
				<?php endif; ?>
				<?php if($items->getShowImage2()):?>
					<img src="<?php echo thumb(fileTarget($USER->getId(),$items->getShowImage2()),80,80);?>" /> 
					&nbsp;&nbsp;&nbsp;
				<?php endif; ?>
				<?php if($items->getShowImage3()):?>
					<img src="<?php echo thumb(fileTarget($USER->getId(),$items->getShowImage3()),80,80);?>" /> 
					&nbsp;&nbsp;&nbsp;
				<?php endif; ?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2">Upload hospitality rider (optional):</div>
			<div class="column grid_4">
				<?php echo form_upload('hospitality_rider',"", 'id="hospitality_rider" size="30"');?>
				
				<div class="clrboth"></div>
				<span class="hidden" id="hospitality_rider_error"><span class="red">File upload missing.</span><br />
					Max file allow: <?php echo allowMaxFileSize();?> MB. <br/>
					Allow extension: <?php echo implode( ', ',allowExtensionFileDocumentUpload() );?>
				</span>
				<div class="clrboth"></div>
				<?php if($items->getHospitalityRider()): ?>
					<a href="<?php echo fileTarget($USER->getId(),$items->getHospitalityRider());?>" target="_blank"><?php echo $items->getHospitalityRider();?></a>
				<?php endif; ?>
			</div>
			
			<div class="clrboth"></div>
			<div class="column grid_2">
				<b>Terms and Conditions:</b>
			</div>
			<div class="column grid_6">
				Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
			</div>
			
			<div class="clrboth"></div>
				
			<br/>
			<div class="column grid_2">
				&nbsp;
				<input type="hidden" name="show_id" id="show_id" value="<?php echo $items->getId();?>" />
			</div>
			<div class="column grid_6">
				<div id="targetBack" class="red"></div>
				<div class="clrboth"></div>
				<input type="submit"  id="button_submit_show" name="button_submit_show" value="Save show" class="ui-corner-all button-yellow" />
				&nbsp;&nbsp;&nbsp;
				<?php echo loader_image(" class='hidden' id='loader' ");?>
			</div>
		
			<div class="clrboth"></div>
		</div>
	</div>
	
</form>	
</div>
<div class="clrboth"></div>

<script type="text/javascript">
	$(function() {
	/*	$( "#start_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-MM-yy'
		});
		$( "#end_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-MM-yy'
		});
	*/	
		var dates = $( "#start_date, #end_date" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-MM-yy',
			numberOfMonths: 3,
			onSelect: function( selectedDate ) {
				var option = this.id == "start_date" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
		$( "#bid_due_date" ).datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-MM-yy'
		});
		
		$('#__private,#__commercial').bind('click',function (){
			$_private = $('#__private').attr('checked');
			$_commercial = $('#__commercial').attr('checked');
			if($_private || $_commercial){
				 $('#__public').attr('checked',false);
			}
		});
		
		$('#__public').click(function(){
			$_public = $('#__public').attr('checked');
			if($_public){
				$('#__private').attr('checked',false);
				$('#__commercial').attr('checked',false);
			}
		});
		//Date.parse("07-September-2011").compareTo( Date.parse('3-September-2011'))   
	});
	
	function add_more(){
		$('#show_image_2,#show_image_3').fadeIn('slow');
	}
</script>
